package com.tongchengsoft.interceptors;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

/**
 * 异常拦截器
 * @author lijh
 *
 */
public class ExceptionHandler implements HandlerExceptionResolver{

	private static Logger logger = Logger.getLogger(ExceptionHandler.class);
	
	@Override
	public ModelAndView resolveException(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex) {
		String path = request.getContextPath();
		ex.printStackTrace();
		logger.error("error is :", ex);
		request.setAttribute("base_path", path);
		System.out.println("Come");
		return new ModelAndView("/common/page/404.html");
	}
}
